/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package beans.ejb;

import entities.Fantasydraftresult;
import entities.Fantasyleague;
import entities.Fantasyteam;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author The Lunatics
 */
@Stateless
public class FantasydraftresultFacade extends AbstractFacade<Fantasydraftresult> {

    @PersistenceContext(unitName = "Touchdown308PU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public FantasydraftresultFacade() {
        super(Fantasydraftresult.class);
    }

    public List<Fantasydraftresult> findDraftResultByLeagueId(Fantasyleague leagueId) {
        javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery();
        Query q = getEntityManager().createNamedQuery("Fantasydraftresult.findByLeagueId");
        q.setParameter("leagueId", leagueId);
        return q.getResultList();
    }
    
    public List<Fantasydraftresult> findDraftResultByLeagueIdTeamId(Fantasyleague leagueId, Fantasyteam teamId) {
        javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery();
        Query q = getEntityManager().createNamedQuery("Fantasydraftresult.findByLeagueIdteamId");
        q.setParameter("leagueId", leagueId);
        q.setParameter("teamId", teamId);
        return q.getResultList();
    }
}
